﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Threading;

namespace PublishIP
{
    class IpService
    {
        ILogService _logService;
        public IpService(ILogService logService)
        {
            _logService = logService;
        }
        public void StartPublishIp(string host,string name, string password)
        {
            while (true)
            {
                try
                {
                    using (WebClient webClient = new WebClient())                        
                        webClient.DownloadString($"http://{host}/ipservice/setip?name={name}&pwd={password}");
                    Thread.Sleep(500);
                }
                catch (Exception ex)
                {
                    _logService.Log(ex.ToString());
                }
            }

        }
    }
}
